package resources.lectureRoom;

import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import dao.LectureRoomDAO;
import dao.Linker;

import model.lectureRoom.LectureRoom;

public class ScheduleRes 
{
	@Context
	UriInfo uriInfo;
	
	@Context
	Request request;
	
	String scheduleId;
	
	public ScheduleRes(UriInfo uriInfo, Request request, String scheduleId) 
	{
		this.uriInfo = uriInfo;
		this.request = request;
		this.scheduleId = scheduleId;
	}
	
	@GET
	@Produces(MediaType.TEXT_XML)
	public LectureRoom getDataBrowser() 
	{
		Linker.sort();
		
		LectureRoom lectureRoom = LectureRoomDAO.getLectureRoomsScheduleCP().get(scheduleId);
		
		if(lectureRoom == null)
			throw new RuntimeException("Get: Lecture room schedule " + scheduleId +  " not found");
		return lectureRoom;
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public LectureRoom getDataBrowserJSON() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XHTML_XML)
	public LectureRoom getDataBrowserXHTML() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XML)
	public LectureRoom getDataBrowserXML() 
	{
		return getDataBrowser(); 
	}
}